// pages/order_detail/index.js
import {
    ReMallShopping
} from "../../api/index.js"
import {
    ReIndex
} from "../../api/order.js"
import {
    getNavigationbar
} from "../../api/index.js"
import {
    ReDistributionMall,
    ReMallPay
} from "../../api/shipping.js"
Page({
    options: {
        styleIsolation: "shared"
    },
    /**
     * 页面的初始数据
     */
    data: {
        orderdetail: {},
        paramsOBj: {},
        resDobj: {},
        interval: '',
        scrollViewHeight: 0,
        deaeTime: '',
        deadlineTime: '',
        serceTime:0,
        out_trade_no: '',
        goodsList: [{
            supLogo: "/images/element_christmas_xls@2x.png",
            supName: "供应商名称",
            orderState: 1, // 0-交易成功1-已发货2-已付款3-未付款4-交易完成5-交易关闭
            storageState: false, // false-未入库true-入库完成
            behalfState: false, // 是否代发
            supGoodsList: [{
                goodsImg: "/images/element_christmas_xpzq@2x.png",
                goodsName: "商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称",
                goodsPrice: "310.00",
                goodsSpecs: "规格规格规格个规格规格规格规格规格规格个规格规格规格",
                goodsSpecsCount: 2
            }]
        }],
        btnList: [{
                text: "联系客服",
                type: "contact"
            },
            {
                text: "批量退款",
                type: "remove"
            },
            {
                text: "查看物流",
                type: "s"
            },
            {
                text: "确认收货",
                type: "edit"
            },
        ]
    },
    suuViewDetail(val) {
        console.log('e',val)
        getNavigationbar({
            act: 'goods_refund_list',
            id: val.target.dataset.val.id,
            orderid: val.target.dataset.val.orderid,
        }).then(res => {
           console.log('res',res)
           val.currentTarget.dataset.value.id = res[0].id
           val.currentTarget.dataset.value.status = res[0].status
           val.currentTarget.dataset.value.isclose = res[0].isclose
            wx.navigateTo({
                url: `/pages/order_refund_detail/index?data=${JSON.stringify(val)}`
            })  
      

        });
       
    },
    /**
     * 首页跳转商品详情页回调函数方法
     */
    handleGoodsDetail(e) {
        const {
            value
        } = e.currentTarget.dataset
        console.log('e', e)
        const params = {
            goodsId: "",
            area: "",
            detailType: 1,
            act: "good_detail"
        }
        if (value) {
            const {
                goodsid,
                productid
            } = e.currentTarget.dataset.value
            if (goodsid) {
                params.goodsId = goodsid
            } else {
                params.goodsId = productid
            }
        } else {
            const {
                productid
            } = e.currentTarget.dataset.value
            params.goodsId = productid
        }
        wx.navigateTo({
            url: `/pages/goods_detail/index?data=${JSON.stringify(params)}`,
        })
    },
    /**
     * 查看退款详情回调函数方法
     */
    handleViewDetail(val) {
        console.log('val', val)
        getNavigationbar({
            act: 'goods_refund_list',
            id: val.target.dataset.val.id,
            orderid: val.target.dataset.val.orderid,
        }).then(res => {
            let list = []
            res.forEach(element => {
                list.push(`${this.getTes(element.inputtime)} 发起的售后单`)
            });
            wx.showActionSheet({
                itemList: list,
                success: function (resj) {
                    if (!resj.cancel) {
                        console.log('用户点击了', resj.tapIndex)
                        val.currentTarget.dataset.value.id = res[resj.tapIndex].id
                        val.currentTarget.dataset.value.status = res[resj.tapIndex].status
                        val.currentTarget.dataset.value.isclose = res[resj.tapIndex].isclose
                        wx.navigateTo({
                            url: `/pages/order_refund_detail/index?data=${JSON.stringify(val)}`
                        })
                    }
                }
            })
           
            console.log('查看退款详情回调函数方法', this.getTes(res[0].inputtime), res)

        });

    },
    // 取消订单
    cancellationOrder(val) {
        console.log('val', val)
        let that = this;
        wx.showModal({
            title: '订单取消',
            content: '取消后无法恢复',
            showCancel: true, // 是否显示取消按钮，设为true表示显示
            confirmText: '确定取消', // 确定按钮的文本
            cancelText: '暂不取消', // 取消按钮的文本
            confirmColor: '#ff0000', // 确定按钮的颜色
            cancelColor: '#999999', // 取消按钮的颜色
            contentColor: '#000000', // content文本颜色
            success(res) {
                if (res.confirm) {
                    console.log('用户点击确定');
                    getNavigationbar({
                        act: 'cancelOrder',
                        id: val.currentTarget.dataset.value.orderid,
                        agentid: val.currentTarget.dataset.value.agentid,
                    }).then(res => {
                        console.log('取消后无法恢复', res)
                        that.getOrderdetails(that.data.resDobj)
                        that.getTime()
                        wx.navigateBack()
                    });
                } else if (res.cancel) {
                    console.log('用户点击取消');

                }
            }
        });
    },
    // 检测订单支付状态的函数
    checkPaymentStatus() {
        if (this.data.out_trade_no != '') {
            ReMallShopping({
                act: 'check_order_state',
                out_trade_no: this.data.out_trade_no,

            }).then(res => {
                if (res.ispay == 1) {
                    wx.reLaunch({
                        url: '/pages/order_list/index',
                    })
                } else {
                    wx.showModal({
                        title: '',
                        content: '订单未支付',
                        showCancel: false, // 是否显示取消按钮，设为false表示不显示
                        confirmText: '确定', // 确定按钮的文本
                        success(res) {
                            if (res.confirm) {
                                wx.redirectTo({
                                    url: '/pages/order_list/index',
                                })
                            }
                        }
                    });
                }
                console.log('检测订单支付状态的函数', res)
            })
        }
    },
    /**
     * 支付继续付款
     */
    payment(val) {

        console.log('支付', val)
        getNavigationbar({
            act: 'repay',
            id: val.target.dataset.value,

        }).then(resj => {
            console.log('支付', resj)
            let openids = wx.getStorageSync('OPENID')
            let token = wx.getStorageSync('TOKEN')
            this.data.out_trade_no = resj.out_trade_no
            if (resj.result == 101) {
                wx.showModal({
                    title: '',
                    content: resj.msg,
                    showCancel: false, // 是否显示取消按钮，设为false表示不显示
                    confirmText: '确定', // 确定按钮的文本
                    success(res) {
                        if (res.confirm) {
                            console.log('用户点击确定');
                        }
                    }
                });
                return
            }
            ReMallPay({
                act: "mini_wechat_commit",
                appid: 'wx11508f3ee9dd6329',
                openid: openids,
                channel: "",
                "out_trade_no": resj.out_trade_no
            }).then(res => {
                let that = this;
                console.log('微信支付', res)
                // 在需要显示带有确定按钮的模态框的地方调用该方法
                if (res.result == 101) {
                    wx.showModal({
                        title: '',
                        content: res.msg,
                        showCancel: false, // 是否显示取消按钮，设为false表示不显示
                        confirmText: '确定', // 确定按钮的文本
                        success(res) {
                            if (res.confirm) {
                                console.log('用户点击确定');
                            }
                        }
                    });
                } else {
                    if (res.channel == 'mini_wechat') {
                        // 跳转到汇付小程序进行支付操作
                        wx.navigateToMiniProgram({
                            appId: res.appid,
                            envVersion: 'trial',
                            path: res.path + '?out_trade_no=' + resj.out_trade_no + '&token=' + token + '&type=mini_program',
                            success(res) {
                                // setTimeout(() => {
                                //     that.checkPaymentStatus()
                                // }, 1000);
                                // 支付完成后返回的回调函数
                                wx.redirectTo({
                                    url: '/pages/order_list/index',
                                })
                            },
                            fail(res) {
                                console.log('res123', )
                                setTimeout(() => {
                                    // that.checkPaymentStatus()
                                }, 1000);
                                // 跳转失败的处理逻辑

                            }
                        });
                    } else {
                        wx.requestPayment({
                            provider: "wxpay",
                            appid: "wx11508f3ee9dd6329",
                            timeStamp: res.timestamp,
                            nonceStr: res.noncestr,
                            package: res.package,
                            partnerid: res.partnerid,
                            signType: res.sign_type,
                            paySign: res.sign,
                            success: function (res) {
                                // 支付成功的回调
                                console.log('支付成功的回调', res)

                                this.getOrderdetails(this.data.resDobj)
                                this.getTime()
                            },
                            fail: function (res) {
                                // 支付失败的回调
                                wx.showToast({
                                    title: '取消支付',
                                    icon: 'none',
                                    duration: 2000
                                });
                                console.log('支付失败的回调', res)
                            }
                        });
                    }


                }
            })

        });
    },
    /**
     * 返回上一页
     */
    onClickLeft() {
        wx.reLaunch({
            url: '/pages/order_list/index',
        })
    },

    /**
     * 复制退款编号回调函数方法
     * @param {*} e 
     */
    handleCopy(e) {
        console.log('复制退款编号', e);
        wx.setClipboardData({
            data: e.currentTarget.dataset.value,
            success: function (res) {
                // wx.getClipboardData({
                //     success: function (res) {
                //         console.log(res.data); // 输出：'要复制的内容'
                //     }
                // });
            }
        });
    },
    /**
     * 跳转
     * @param {*} event 
     */
    enter(event) {
        console.log('e', event)
        let obj = {
            ...event.currentTarget.dataset.value,
            agent_name: event.currentTarget.dataset.value.agent_name
        }
        let objStr = encodeURIComponent(JSON.stringify(obj));
        wx.navigateTo({
            url: '/pages/brand_detail/index?obj=' + objStr,
        })
    },
    getTes(inputtime) {
        const timestamp = inputtime;

        const date = new Date(timestamp * 1000);
        const year = date.getFullYear();
        const month = date.getMonth() + 1;
        const day = date.getDate();
        const hours = date.getHours();
        const minutes = date.getMinutes();
        const seconds = date.getSeconds();
        const formattedDateTime = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day} ${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`;
        return formattedDateTime;
    },
    /**
     * 订单详情
     */
    getOrderdetails(item) {
        var that = this; // 保存当前对象的引用
        ReMallShopping({
            act: 'orderdetaillist',
            orderid: item.id || ''
        }).then(res => {

            const timestamp = res.inputtime;

            const date = new Date(timestamp * 1000);
            const year = date.getFullYear();
            const month = date.getMonth() + 1;
            const day = date.getDate();
            const hours = date.getHours();
            const minutes = date.getMinutes();
            const seconds = date.getSeconds();
            const formattedDateTime = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day} ${hours < 10 ? '0' + hours : hours}:${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`;
            res.dateTime = formattedDateTime;
            this.data.orderdetail = res
            this.data.deaeTime = timestamp

            // res.dateTime =  this.getTes( res.inputtime);
            res.dTime = this.getTes(res.pay_time);
            console.log('订单详情', res);

            const statuStr = this.getStatusString(res);
            res.statuStr = statuStr;
            console.log('statuStr=====', statuStr, res)
            this.setData({
                // paramsOBj: res,
                orderdetail: res,
            });

            // this.getTime()
        });
    },
    getStatusString(element) {
        let statuStr = "";

        if (element.order_type == 5) {
            statuStr = element.isrefund == 1 ? "集采失败，已退款" : "集采失败，退款失败";
        } else if (element.isrefund == 2) {
            statuStr = "交易关闭";
        } else {
            switch (parseInt(element.status)) {
                case 0:
                case 4:
                    statuStr = element.ispay == 1 ? "已付款" : (element.paytype == 9 ? "线下支付，未发货" : "未付款");
                    if (element.ispay == 1 && element.order_type == 5) {
                        statuStr = element.pintuan_state == 1 ? "集采成功，待发货" : (element.pintuan_state == 0 ? "已付款，待成团" : "集采失败");
                    }
                    break;
                case 1:
                case 2:
                case 3:
                    statuStr = "已发货";
                    break;
                case 5:
                    statuStr = element.flag == 0 ? "交易成功" : (element.flag == 1 ? "交易成功|待确认入库" : "交易成功|入库完成");
                    break;
                case 8:
                    statuStr = "已结算";
                    break;
                case 9:
                case 10:
                    statuStr = "交易关闭";
                    break;
                case 11:
                    if (element.recieve_days ?? 0 <= 7) {
                        statuStr = element.flag == 0 ? "交易成功" : (element.flag == 1 ? "交易成功|待确认入库" : "交易成功|入库完成");
                    } else {
                        statuStr = element.flag == 0 ? "交易完成" : (element.flag == 1 ? "交易完成|待确认入库" : "交易完成|入库完成");
                    }
                    break;
                default:
                    console.log('执行结束');
                    statuStr = "";
            }
        }

        return statuStr;
    },
    gett() {
        let that = this
        console.log('this.data.orderdetail', this.data.deaeTime)
        this.setData({
            interval: setInterval(() => { //业务逻辑
                var currentTimestamp = Math.floor(Date.now() / 1000); // 获取当前系统时间戳（单位：秒）
                var inputTime = parseInt(this.data.deaeTime); // 假设这是一个input时间戳，表示2024-07-20 00:00:00

                var oneDaySeconds = 24 * 60 * 60; // 一天的秒数

                if ((currentTimestamp - inputTime) > oneDaySeconds) {
                    console.log('支付已超时');
                    clearInterval(this.data.interval);
                } else {
                    var resultTime = inputTime + oneDaySeconds; // 计算超过1天后的时间戳


                    var currentTime = Math.floor(Date.now() / 1000); // 获取当前系统时间戳（单位：秒）
                    var timeDiff = resultTime - currentTime; // 计算时间差

                    if (timeDiff <= 0) {
                        clearInterval(this.data.interval); // 倒计时结束时清除定时器
                        console.log('支付时间已到');
                    } else {
                        var days = Math.floor(timeDiff / (24 * 60 * 60));
                        var hours = Math.floor((timeDiff % (24 * 60 * 60)) / (60 * 60));
                        var minutes = Math.floor((timeDiff % (60 * 60)) / 60);
                        var seconds = timeDiff % 60;

                        console.log('剩余时间：' + days + hours + '小时 ' + minutes + '分钟 ' + seconds + '秒');
                        let time = hours + ': ' + minutes + ': ' + seconds
                        that.data.deadlineTime = time
                        that.setData({
                            deadlineTime: time
                        })
                    }

                }
            }, 1000)
        })
    },
    getTime() {
        ReIndex({
            act: 'server_config',
        }).then(res => {
            console.log('支付时间', res);
            this.data.serceTime = res.server_time
            // 获取当前时间戳
            const currentTimestamp = res.server_time;

            // 假设订单详情中的时间戳为res.inputtime
            const orderTimestamp = parseInt(this.data.orderdetail.inputtime);

            // 计算时间差
            let timeDiff = currentTimestamp - orderTimestamp;
            const oneDayInSeconds = 24 * 60 * 60;
            console.log('timeDiff', timeDiff)
            if (timeDiff < 0) {
                // 支付已超时
                console.log("支付已超时");

            } else if (timeDiff > oneDayInSeconds) {
                // 支付已超时
                console.log("支付已超时");

            } else {

                // 请于\(inputtime)前完成支付
                const deadline = new Date(orderTimestamp * 1000).toLocaleString();
                console.log("请于 " + deadline + " 前完成支付");
            }
            clearInterval(this.data.interval)
            console.log('时间', this.data.orderdetail.inputtime);
        });
    },


    /**
     * 退款操作按钮回调函数方法
     * @param {*} e 
     */
    handleSubmit(e) {
        let type = e.currentTarget.dataset.type
        switch (type) {
            case 'edit':
                getApp().Tips({
                    title: "点击了修改申请"
                })
                break;
            case 'remove':
                wx.showModal({
                    title: '温馨提示',
                    content: '确认撤销申请退款么',
                    confirmColor: '#FE3A22',
                    cancelColor: '#1A191E',
                    complete: (res) => {
                        if (res.cancel) {
                            console.log('点击取消按钮');
                        }
                        if (res.confirm) {
                            console.log('点击确认按钮');
                        }
                    }
                })
                break;
            case 'contact':
                getApp().Tips({
                    title: "点击了联系客服"
                })
                break;
        }
    },

    // 查看物流
    getViewlogistic(e) {
        console.log('e', e)
        getNavigationbar({
            act: 'getlogistics',
            "is_multiterm": 1,
            orderid: this.data.resDobj.id || ''
        }).then(res => {
            console.log('查看物流', res)
            if (res.result == 84115) {
                wx.nextTick(() => {
                    wx.showModal({
                        title: '',
                        content: res.msg,
                        showCancel: false, // 是否显示取消按钮，设为false表示不显示
                        confirmText: '确定', // 确定按钮的文本
                        success(res) {
                            if (res.confirm) {
                                console.log('用户点击确定');
                            }
                        }
                    });
                })
            } else {
                wx.navigateTo({
                    url: '/subpackages/pages/sub1/index?data=' + JSON.stringify(e.target.dataset.value.orderid)
                });
            }
        })
    },
    Batchrefund(e) {
        console.log('e', e)
        let data = e.currentTarget.dataset.value
        let num = 0
        let maxrefund = 0
        let hasNavigated = false; // 添加标记变量
        let max = 0
        this.getTime()
        console.log('e', e,parseFloat(this.data.serceTime), parseFloat(data.finish_time));
        if(parseFloat(this.data.serceTime)  > parseFloat(data.finish_time) && data.finish_time != 0) {
            wx.showModal({
                title: '',
                content: '超过退款时效，请联系客服',
                showCancel: true, // 是否显示取消按钮，设为false表示不显示
                confirmText: '联系客服', // 确定按钮的文本
                success(res) {
                    if (res.confirm) {
                        that.freeTell()
                    }
                }
            });
            return
        }
        data.detail.forEach(element => {
            num += parseInt(element.can_refund)
            maxrefund += parseInt(element.can_refund)
            max += parseInt(element.max_refund)
            console.log('sawdawdawdawdaw', element.max_refund, 'max', max)
        })

        data.detail.forEach(element => {
            // num += parseInt(element.numbers) pages/choose_after_sales_type/index
            // if(element.max_refund >)

            console.log('num', num)
            if (num == 0 && maxrefund == 0) {
                wx.showToast({
                    title: '没有可退款的商品!',
                    icon: 'none',
                    duration: 2000
                });
            } else {
                console.log('进', element, data.detail)
                data.all = 'alone'

                if (data.detail.length > 1 && element.can_refund > 0 && element.max_refund > 0) {
                    console.log('-------1')
                    if (!data.detail.some(item => item.id === element.id)) {
                        data.detail.push(element);
                    }
                    data.detail.forEach(element => {

                        element.numbers = element.max_refund
                    });
                    // subpackages/pages/select_product/index
                    if (num <= 1) {
                        data.detail = [{
                            ...element
                        }]
                        if (!hasNavigated) {
                            wx.navigateTo({
                                url: '/pages/choose_after_sales_type/index?data=' + JSON.stringify(data),
                            })
                            hasNavigated = true; // 设置标记变量为true 
                        }
                    } else {
                        console.log('-------2')
                        if (!hasNavigated) {
                            wx.navigateTo({
                                url: '/subpackages/pages/select_product/index?data=' + JSON.stringify(data),
                            })
                            hasNavigated = true; // 设置标记变量为true
                        }
                    }
                } else {
                    data.detail.forEach(element => {

                        if (parseInt(element.numbers) == 1 && max <= 1) {
                            data.detail = [{
                                ...element
                            }]
                            if (!hasNavigated) {
                                console.log('总数', max)
                                wx.navigateTo({
                                    url: '/pages/choose_after_sales_type/index?data=' + JSON.stringify(data),
                                })
                                hasNavigated = true; // 设置标记变量为true
                            }
                        } else {
                            if (max > 1 && element.max_refund > 0) {
                                console.log('啦啦啦啦啦啦啦啦', element)

                                data.detail.push(element)
                            } else {
                                // data.detail = [{
                                //     ...element
                                // }]
                            }

                            console.log('-------2', data)
                            if (!hasNavigated) {
                                wx.navigateTo({
                                    url: '/subpackages/pages/select_product/index?data=' + JSON.stringify(data),
                                })
                                hasNavigated = true; // 设置标记变量为true
                            }
                        }
                    });
                }
            }
        });
    },
    showActi() {
        wx.showActionSheet({
            itemList: ['选项一', '选项二', '选项三'],
            success: function (res) {
                if (!res.cancel) {
                    console.log('用户点击了', res.tapIndex)
                }
            }
        })
    },

    // 联系客服
    freeTell() {
        wx.makePhoneCall({
            phoneNumber: "18377766475", //仅为示例，并非真实的电话号码
            success: function () {
                console.log("拨打电话成功！");
            },
            fail: function () {
                console.log("拨打电话失败！");
            },
        });
    },
    // 确认收货
    Confirmreceipt(e) {
        console.log('e', e)
        let that = this
        wx.showModal({
            title: '提示',
            content: '确认收货',
            showCancel: true, // 是否显示取消按钮，设为false表示不显示
            confirmText: '确定', // 确定按钮的文本
            cancelText: "取消",
            success(res) {
               
                if (res.confirm) {
                    console.log('用户点击确定',that.data.resDobj);
                    getNavigationbar({
                        act: 'confirm_receipt',
                        agentid: that.data.resDobj.agentid || '',
                        orderid: that.data.resDobj.id || ''
                    }).then(res => {
                        console.log('确认收货', res)
                        if (res.result == 84115 || res.length == 0) {
                            wx.nextTick(() => {
                                
                                that.getOrderdetails(that.data.resDobj)
                                that.getTime()
                                wx.showToast({
                                    title: '收货成功!',
                                    icon: 'none',
                                    duration: 2000
                                });
                            })
                        }
                    })
                }
            }
        });

    },
    /**
     * 申请售后回调函数方法
     */
    handleAfterSales(e) {
        let data = e.currentTarget.dataset.value;
        let onApdata = e.currentTarget.dataset.val;
        let that = this
        data.all = 'alone';
        // if(data.finish_time)
        this.getTime()
        console.log('e', e, onApdata,parseFloat(this.data.serceTime), parseFloat(data.finish_time));
        if(parseFloat(this.data.serceTime)  > parseFloat(data.finish_time) && data.finish_time != 0) {
            wx.showModal({
                title: '',
                content: '超过退款时效，请联系客服',
                showCancel: true, // 是否显示取消按钮，设为false表示不显示
                confirmText: '联系客服', // 确定按钮的文本
                success(res) {
                    if (res.confirm) {
                        that.freeTell()
                    }
                }
            });
            return
        }
        let hasNavigated = false; // 添加标记变量

        if (onApdata.refund_state == 1 && onApdata.can_refund == 0 && onApdata.max_refund == 0) {
            if (!hasNavigated) {
                wx.navigateTo({
                    url: '/pages/order_refund_detail/index?data=' + JSON.stringify(data),
                });
                hasNavigated = true; // 设置标记变量为true pages/choose_after_sales_type/index
            }
            return; // 跳出函数
        }

        data.detail.forEach(element => {
            element.thumb = 'https://static.chonglaoban.cn' + element.thumb;
            // element.numbers = element.max_refund;

            if (parseInt(onApdata.numbers) == parseInt(element.numbers)) {
                if (onApdata.can_refund == 1 && onApdata.max_refund == 1) {
                    element.numbers = onApdata.can_refund;
                    data.detail = [{
                        ...onApdata
                    }];
                    if (!hasNavigated) {
                        wx.navigateTo({
                            url: '/pages/choose_after_sales_type/index?data=' + JSON.stringify(data),
                        });
                        hasNavigated = true; // 设置标记变量为true
                    }
                    return; // 跳出循环
                } else {
                    data.detail = [{
                        ...onApdata
                    }];
                    console.log('-------');
                    if (!hasNavigated) {
                        wx.navigateTo({
                            url: '/subpackages/pages/select_product/index?data=' + JSON.stringify(data),
                        });
                        hasNavigated = true; // 设置标记变量为true
                    }
                    return; // 跳出循环
                }
            }
        });
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
       
        if (options.data) {
            const params = JSON.parse(options.data)

            const data = params.currentTarget.dataset.value
            this.data.resDobj = data
            wx.setNavigationBarTitle({
                title: data.statuStr // 设置标题名称为"商品详情"
            });
            this.setData({
                paramsOBj: data,
                detailType: params.detailType
            })

            console.log('进', params)
            this.getOrderdetails(data)
            setTimeout(() => {
                this.gett()
            }, 100)
            this.computeScrollViewHeight()
        }
        // 获取手机屏幕高度并进行适配

    },
    /**
     * 计算页面可滚动区域的动态高度
     */
    computeScrollViewHeight() {
        let that = this
        wx.getSystemInfo({
            success: function (res) {
                const windowHeight = res.windowHeight;
                console.log('手机屏幕高度：', windowHeight);

                // 进行适配操作，例如设置元素高度为屏幕高度的一半
                const halfScreenHeight = windowHeight / 2;
                console.log('屏幕高度的一半：', halfScreenHeight);
                that.setData({
                    scrollViewHeight: windowHeight
                })
            }
        });
    },
    stopTimer() {
        clearInterval(this.data.interval);
        console.log('定时器已停止。');
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },
    beforeunload() {
        this.stopTimer()
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.getTime()
        this.getOrderdetails(this.data.resDobj)
        // this.checkPaymentStatus()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {
        console.log('走2--', this.data.interval)
        // this.getTime(this.data.resDobj)

        clearInterval(this.data.interval)
    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {


        this.stopTimer()
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})